 

package com.zdkj.subway.rca.controller;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.rca.service.SwCkStationDailyReportAdjustService;
import com.zdkj.subway.rca.service.SwCkStationDailyReportOriginalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 报表调账-西安地铁日报表生成 
 *
 * @author stw
 * @date 2020-10-30 15:43:30
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swckstationdailyreportgenerate/" )
@Api(value = "swckstationdailyreportgenerate", tags = "报表调账-西安地铁日报表生成")
public class SwCkStationDailyReportGenerateController {
    @Autowired
    private final SwCkStationDailyReportOriginalService swCkStationDailyReportOriginalService;
    @Autowired
    private final SwCkStationDailyReportAdjustService swCkStationDailyReportAdjustService;

    /**
     * 报表调账-西安地铁收入日报表-生成日报表
     * @return R
     */
    @ApiOperation(value = "生成日报表，settleCycle： 结算周期，必选", notes = "生成日报表，settleCycle： 结算周期，必选")
    @SysLog("报表调账-西安地铁收入日报表-生成日报表" )
    @GetMapping({"/generate"})
    @PreAuthorize("@pms.hasPermission('sw_ck_station_daily_report_generate')" )
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name = "startDate", value = "开始日期：yyyy-MM-dd", dataTypeClass = String.class,required = true),
                    @ApiImplicitParam(name = "endDate", value = "结束日期：yyyy-MM-dd", dataTypeClass = String.class,required = true),
                    @ApiImplicitParam(name = "lineCodes", value = "线路多选", dataTypeClass = String.class,required = false),
            }
    )
    public R generate(String startDate,String endDate,String lineCodes) {
        try {
            if (StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)){
                return R.failed("开始日期和结束日期必选");
            }

            boolean flag = swCkStationDailyReportOriginalService.generate(startDate,endDate,lineCodes);
            //boolean flag2 = false;//swCkStationDailyReportAdjustService.generate(startDate,endDate);

            return R.ok(flag);
        } catch (Exception e) {
            e.printStackTrace();
            return R.failed();
        }

    }

}
